package com.huawei.statistics.service.impl.video;

import com.huawei.statistics.pojo.video.ResoluAddress;
import com.huawei.statistics.service.impl.common.BaseServiceImpl;
import com.huawei.statistics.service.video.ResoluAddressService;
import com.huawei.statistics.vo.common.HttpResult;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by 18573 on 2018/12/28.
 */
@Service
public class ResoluAddressServiceImpl extends BaseServiceImpl implements ResoluAddressService {


    @Override
    public List<ResoluAddress> getResoluAddressList() {
        Map<String,Object> map = new HashMap<>();
        map.put("del",false);
        return getEntityByMap(ResoluAddress.class,map);
    }

    @Override
    public ResoluAddress getResoluAddressById(Long id) {
        return getEntityById(id,ResoluAddress.class);
    }

    @Override
    public HttpResult addResoluAddress(ResoluAddress address) {
        return new HttpResult(HttpResult.OK,addEntity(address));
    }

    @Override
    public HttpResult delResoluAddressById(Long id) {
        ResoluAddress address = getResoluAddressById(id);
        if(address != null){
            address.setDel(true);
        }
        return  updateResoluAddress(address);
    }

    @Override
    public HttpResult updateResoluAddress(ResoluAddress address) {
        return new HttpResult(HttpResult.OK,updateEntityValues(address));
    }
}
